﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DCEdu;

public partial class Login : System.Web.UI.Page
{
    Account objAcc = new Account();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) 
        {
        }
    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        string username = txtUsername.Text.ToString();
        string pass = Utils.DC.Web.UI.Security.Encrypt(txtPassword.Text.ToString());
        if (txtUsername.Text.Equals("") || txtPassword.Text.Equals(""))
        {
            ClientScript.RegisterStartupScript(this.GetType(), "ex", "<script>alert('Thiếu thông tin đăng nhập')</script>");
        }
        else
        {
            if (objAcc.checkLogin(username, pass) == 1)
            {
                Session["UserName"] = this.txtUsername.Text;
                Response.Redirect("CustomerRegister.aspx");                
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "ex", "<script>alert('Sai thông tin đăng nhập')</script>");
            }
        }
    }
}